<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      ul {
        list-style: none;
      }
      div {
        width: 1200px;
        height: 400px;
        border: 2px solid rgb(214, 142, 154);
        background-color: antiquewhite;
        margin: 0 auto;

        ul {
          width: 1200px;
          li {
            width: 240px;
            height: 400px;
            float: left;
            overflow: hidden;
            /* background-image: url(''); */
          }
        }
      }
    </style>
  </head>
  <body>
    <div>
      <ul id="box">
        <li><img src="./images/1.webp" alt="" /></li>
        <li><img src="./images/2.webp" alt="" /></li>
        <li><img src="./images/3.webp" alt="" /></li>
        <li><img src="./images/4.webp" alt="" /></li>
        <li><img src="./images/5.webp" alt="" /></li>
      </ul>
    </div>
  </body>
  <script>
    window.onload = function () {
      var ul = document.getElementById("box");
      var lis = ul.children;
      for (var i = 0; i < lis.length; i++) {
        const item = lis[i];
        // 排他思想:已融入时先把所有的li标签改成宽度为100，把自己改为800
        item.onmouseenter = function () {
          for (var j = 0; j < lis.length; j++) {
            lis[j].style.width = "100px";
          }
          item.style.width = "800px";
        };
        ul.onmouseleave = function () {
          for (var j = 0; j < lis.length; j++) {
            lis[j].style.width = "240px";
            
          }
        };
      }
    };
  </script>
</html>
